#ifndef NFILELISTMODEL_H
#define NFILELISTMODEL_H

#include <QAbstractTableModel>

#ifdef  N_PHONON
#include <phonon/phononnamespace.h>
#include <phonon/mediaobject.h>
#endif

class QModelIndex;
class NMusicFile;

class NFileListModel : public QAbstractTableModel{
    Q_OBJECT
    
signals:
    void selectedSongChanged(NMusicFile *);
    
private:
    QList<NMusicFile *> records;
    int _encoding;
    
#ifdef  N_PHONON    
    Phonon::MediaObject *music;
    int playingRow;
    bool isPlaying;
    bool isOpening;
#endif
        
public slots:	
    void sSelectedRowChanged(const QModelIndex &cur, const QModelIndex &pre);
    
public:
    NFileListModel();
    ~NFileListModel();

    virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
    virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
    virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
    virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;

    void addFiles(const QStringList &filePaths);
    void addFile(const QString &filePath);
    void clear();
    
    int encoding() const;
    void setEncoding(const int x);
    
    int recordsCount() const;
    
    void saveAll();
    
    
private:
    void startPlaying();
    void pausePlaying();
};

#endif // NFILELISTMODEL_H
